<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Properties"%>
<%@page import="dto.mailDTO"%>
<%@page import="vo.mailVO"%>
<%@page import="com.sun.mail.imap.IMAPFolder"%>
<%@page import="javax.mail.Session"%>
<%@page import="javax.mail.Store"%>
<%@page import="javax.mail.Folder"%>
<%@page import="javax.mail.Address"%>
<%@page import="javax.mail.Message"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>mail_List</title>
<link rel="stylesheet" href="../css/mail.css">
<script src = '../js/mail.js'></script>
</head>
<body>
<% request.setCharacterEncoding("utf-8");	 %>
<jsp:useBean id="vo" class="vo.mailVO" scope="page"/>
<jsp:setProperty property="*" name="vo"/>
<%
	System.out.print("내 리스트 사이즈 : " + vo.getNowPage());
	mailDTO dto = new mailDTO();
	ArrayList<mailVO> al = dto.list(vo);
%> 
<p>
<div class='mail_name'>
	<div class="mail_name_view"><h2><%=vo.getEmail_list()%></h2></div></div>
<p>
<div>	
	<div id = 'mail_list_title'>
		<div class='mail_list_sender'>보낸이</div>
		<div class='mail_list_title'>제목</div>
		<div class='mail_list_date'>날짜</div>
		<div class='mail_list_size'>크기</div>
	</div>

<%
System.out.print("al.size()" +  al.size());

	 for(int a=al.size()-1; a>=0; a--){
%>	 		
	
 <div class="mail_list_items">
		<div class='mail_list_sender'><%=al.get(a).getEmail_sender() %></div>
		<div class="mail_list_title">
				<a href = '#' onclick="goView(<%=dto.getNowPage()%>,<%=a%>)">
					<% 	if(al.get(a).getEmail_subject().length()>20){
						String title = al.get(a).getEmail_subject().substring(0, 20); %>
			    		<%=title%>...
					<%} else {%>
						<%=al.get(a).getEmail_subject()%>
					<%}
						
					%>
					
					
					</a>
		</div>
		<div class='mail_list_date'><%=al.get(a).getEmail_date()%></div>
		<div class='mail_list_size'><%=al.get(a).getEmail_size()%></div>		
</div>	
	<%}%>
	
</br>
 <div id = 'list_page' align="center">
		<% if(dto.getNowPage()==1){%>
		[처음으로]
		<%}else{%><a href='#' onclick='goPage(1)'>[처음으로]  </a>
		<%}%>
		
	<% if(dto.getNowBlock()==1){%>
		[이전으로]
		<%}else{%><a href="#" onclick='goPage(<%=dto.getStartPage()-1 %>)'> [이전으로] </a>
		<%} %>	
	<%	
	int j=0;
	for(j = dto.getStartPage(); j<=dto.getEndPage(); j++){%>
	<a href= "#" onclick = "goPage(<%= j %>)"><%= j %></a>
	<%} %>
	<% if(dto.getNowBlock()==dto.getTotBlock()){%>
		[다음으로]
		<%}else{%><a href= '#' onclick = "goPage(<%=j %>)">  [다음으로] </a>
		<%} %>
	
	<% if(dto.getNowPage()==dto.getTotPage()){%>
		[맨끝으로]
		<%}else{%><a href= "#" onclick = "goPage(<%=dto.getTotPage() %>)">  [맨끝으로] </a>
		<%} %>	
	
</div> 	
<hr>
</div>
	<form name = 'hFrm' method='post'>
		<input type='hidden' name="nowPage" value="<%=dto.getNowPage()%>"/>
	 	<input type='hidden' name='m_id' value="<%=vo.getM_id()%>"/>
	 	<input type='hidden' name='email_number' />
		<input type="hidden" name="email_list" value="<%=vo.getEmail_list()%>"/>
		<input type="hidden" name="email_address" value="<%=vo.getEmail_address()%>">
		<input type="hidden" name="email_pwd" value="<%=vo.getEmail_pwd()%>"/>
		<input type="hidden" name="e_name" value="<%=vo.getE_name()%>"/>
		<input type="hidden" name="email_sender" value="<%=vo.getEmail_sender()%>"/>
		<input type="hidden" name="email_receiver" value="<%=vo.getEmail_receiver()%>"/>
		<input type="hidden" name="email_filename" value="<%=vo.getEmail_filename()%>"/>
	</form>
</body> 
</html>